package Thread;

class SinglentonLazy {
    private volatile static SinglentonLazy instance = null;

    public static SinglentonLazy getInstance() {
        if (instance == null) {
            synchronized (SinglentonLazy.class) {
                if (instance == null) {
                    instance = new SinglentonLazy();
                }
            }
        }
        return instance;
    }

    private SinglentonLazy() {}
}

public class ThreadDemo5 {
    public static void main(String[] args) {
        SinglentonLazy s1 = SinglentonLazy.getInstance();
        SinglentonLazy s2 = SinglentonLazy.getInstance();
        System.out.println(s1 == s2);
    }
}

